#include"logger.h"
#include<cstdio>

Logger::Logger() {
	logfile = fopen("./logfile","a");
	if (logfile == 0) throw "Error 1: Could not open file";
}

Logger::Logger(char const * filename) {
	logfile = fopen(filename,"a");
	if (logfile == 0) throw "Error 1: Could not open file";
}

Logger::Logger(Logger const & l) {}

Logger::~Logger() {
	if (logfile != 0) {
		fputs("Logger logging out.\n",logfile);
		fclose(logfile);
	}
}

void Logger::msg(char const * s) {
	fputs(s,logfile);
	fputs("\n",logfile);
}

Logger * Logger::getInstance() {
	static Logger statlog;
	return & statlog;
}